﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;

namespace Alex.Library.Net.Mail {
    /// <summary>
    /// 邮件接口
    /// </summary>
    public interface IMail {
        /// <summary>
        /// 设置邮件服务器地址
        /// </summary>
        /// <param name="address">邮件服务器地址</param>        
        /// <returns></returns>
        IMail SetHost ( string address );
        /// <summary>
        /// 设置邮件服务器端口
        /// </summary>
        /// <param name="port">发送端口，一般为25，GMail/Exchange为587</param>
        /// <returns></returns>
        IMail SetPort ( int port );
        /// <summary>
        /// 设置邮件发送方帐号
        /// </summary>
        /// <param name="userName">用户名，Exchange为"domain\username"</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        IMail SetCredential ( string userName, string password );
        /// <summary>
        /// 设置发送方邮件地址
        /// </summary>
        /// <param name="senderAddress">发送方地址</param>
        /// <returns></returns>
        IMail SetSender ( string senderAddress );
        /// <summary>
        /// 添加收件人地址
        /// </summary>
        /// <param name="recipientAddress">收件人地址</param>
        /// <returns></returns>
        IMail AddRecipient ( string recipientAddress );
        /// <summary>
        /// 添加抄送地址
        /// </summary>
        /// <param name="ccAddress">抄送地址</param>
        /// <returns></returns>
        IMail AddCc ( string ccAddress );
        /// <summary>
        /// 设置邮件标题
        /// </summary>
        /// <param name="subject">标题</param>        
        /// <returns></returns>
        IMail SetSubject ( string subject );
        /// <summary>
        /// 设置邮件标题编码方式
        /// </summary>
        /// <param name="encoding">编码方式</param>
        /// <returns></returns>
        IMail SetSubjectEncoding ( Encoding encoding );
        /// <summary>
        /// 设置邮件内容
        /// </summary>
        /// <param name="body">内容</param>        
        /// <param name="isHTML">内容是否为HTML格式，默认为true</param>
        /// <returns></returns>
        IMail SetBody ( string body, bool isHTML = true );
        /// <summary>
        /// 设置邮件内容编码方式
        /// </summary>
        /// <param name="encoding">编码方式</param>
        /// <returns></returns>
        IMail SetBodyEncoding ( Encoding encoding );
        /// <summary>
        /// 设置邮件优先级
        /// </summary>
        /// <param name="priority">优先级</param>
        /// <returns></returns>
        IMail SetPriority ( MyMailPriority priority );
        /// <summary>
        /// 设置启用/禁用SSL加密
        /// </summary>
        /// <param name="enabled">启用/禁用</param>
        /// <returns></returns>
        IMail SetSslEnabled ( bool enabled );
        /// <summary>
        /// 设置附件大小限制
        /// </summary>
        /// <returns></returns>
        IMail SetAttachmentMaxSize ( long maxSize );
        /// <summary>
        /// 设置附件的类型限制
        /// </summary>
        /// <param name="fileExts">文件扩展名(包含“.”)列表（不区分大小写）</param>
        /// <returns></returns>
        IMail SetAttachmentFileExts ( string[ ] fileExts );
        /// <summary>
        /// 添加附件
        /// </summary>
        /// <param name="filename">附件路径</param>
        /// <returns></returns>
        IMail AddAttachment ( string filename );        
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <returns></returns>
        IMail Send ();
    }

    public enum MyMailPriority {
        Low = 0,
        Normal = 1,
        High = 2,
    }
}
